#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>

using namespace std;

typedef long long LL;

int qmi(int a, int b, int p)
{
    int res = 1 % p;
    while (b)
    {
        if (b & 1)   res = (LL)res * a % p;
        a = (LL)a * a % p;
        b >>= 1;
    }
    return res;
}

int main()
{
    int n, m, k, x;
    scanf("%d%d%d%d", &n, &m, &k, &x);
    printf("%lld\n", (x + (LL)qmi(10, k, n) * m) % n);
    return 0;
}